import input from './input.mjs'
import todolistObj from './toDoList.mjs'
import doneList from './doneList.mjs'
import { store } from '../store/store.js'

export default {
    template: `
    <div id="app">
        <top-bar></top-bar>
        <div class="body">
            <todo-list></todo-list>
            <done-list></done-list>
        </div>
    </div>
    `,
    components:{
        "top-bar":input,
        "todo-list":todolistObj,
        "done-list":doneList
    },
    store: store,
     computed: {
          list() {
               return this.$store.state.list
          },
          doneList() {
               return this.$store.state.doneList
          }
    },
    created() {
        // 从本地存储加载
        this.$store.dispatch("init")
   },

   watch: {
        list() {
             localStorage.setItem("list", JSON.stringify(this.list));
        },
        doneList() {
             localStorage.setItem("doneList", JSON.stringify(this.doneList));
        }
   },
   





}